package com.five.welcome.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.five.welcome.entity.Admissioninfo;
import com.five.welcome.dao.AdmissioninfoMapper;
import com.five.welcome.service.AdmissioninfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdmissioninfoServiceImpl extends ServiceImpl<AdmissioninfoMapper, Admissioninfo> implements AdmissioninfoService {

    @Autowired
    private AdmissioninfoMapper admissioninfoMapper;

    //根据学号获取录取状态
    @Override
    public Admissioninfo getAdmissionInfoBySNumber(String sNumber) {
        QueryWrapper<Admissioninfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("*").
                eq("s_number", sNumber);
        return admissioninfoMapper.selectOne(queryWrapper);
    }

    //分页条件查询
    @Override
    public Page<Admissioninfo> getAllOfPage(Integer pageNumber, Integer pageSize,
                                            String sNumber, String profession,
                                            String admissionStatus) {
        QueryWrapper<Admissioninfo> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq(sNumber!=null,"s_number",sNumber)
                .like(profession!=null,"profession",profession)
                .eq(admissionStatus!=null,"admission_Status",admissionStatus);
        return page(Page.of(pageNumber,pageSize),queryWrapper);
    }

}
